#include<iostream>
#include<stack>

using namespace std;

template<typename T>
class CQueue{
    public:
        CQueue(void){}
        ~CQueue(void){}

        void appendTail(const T& node){
            while ( !stack1.empty() ){
                stack2.push(stack1.top());
                stack1.pop();
            }
            stack2.push(node);
        }
        T deleteHead(){
            while ( !stack2.empty() ){
                stack1.push(stack2.top());
                stack2.pop();
            }
            if ( !stack1.empty()){
                T tmp = stack1.top();
                stack1.pop();
                return tmp;
            }
        }
    private:
        // 栈顶为队首
        stack<T> stack1;
        // 栈顶为队尾
        stack<T> stack2;
};

int main(void){
    CQueue<int> cqueue;
    cqueue.appendTail(2);
    cqueue.appendTail(4);
    cqueue.appendTail(3);
    cout << cqueue.deleteHead() << endl;
    cout << cqueue.deleteHead() << endl;
    cout << cqueue.deleteHead() << endl;
    return 0;
}
// out : 2
// 4
// 3
